﻿using ITXHWEB.Models;
using ReflectionStudio.Core.Events;
using System;
using System.Data;
using System.Web.Mvc;
using WPFExcelReport;
using WPFExcelReport.Helpers;
using ITXHWEB.Infrastructure;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
namespace ITXHWEB.Controllers
{
    public partial class ABFOLGEController
    {
        [ChildActionOnly]
        public ActionResult SRP13START(string returnUrl)
        {
            ModelState.Clear();
            ViewBag.ReturnUrl = returnUrl;
            Helper.GetSTime(ref date, ref time, ref stime);
            MABF.DTSTART = date;
            MABF.TMSTART = stime;
            return PartialView(MABF);
        }
        [HttpPost]
        [AllowAnonymous]
        [ValidateAntiForgeryToken]
        public ActionResult SRP13START(ABFOLGEModel model, string returnUrl)
        {
            try
            {
                ModelState.Clear();
                if (model.BMAUF.Trim().Length == 0)
                    throw new Exception("轴号必扫");
                RP13START(model);
            }
            catch (Exception ex)
            {
                INFO = ex.Message;
                Tracer.Error(ex.StackTrace, ex);
            }
            return RedirectToAction(MAPP, MAPP);
        }
    
        public void RP13START(ABFOLGEModel model)
        {
            MABF.BMAUF = model.BMAUF;
            MABF.BKRS = model.BMAUF.Substring(0, 2);
            MABF.BLFD = model.BMAUF.Substring(2, 6);
            PREPAREPM(model);
            PM["PDCTYPE"] = MABF.PDCTYPE;
            PM["KSLTYPE"] = "LBEAMSTART"; 
            PM["QTY"] =(double)0.0;
            PM["PDCDATE"] = MABF.DTSTART;
            PM["PDCTIMES"] = MABF.TMSTART;
            PM["PDCTIMET"] = MABF.TMSTART;
            PM["PDCTIME"] = MABF.TMSTART;
            PM["BMAUF"] = MABF.BMAUF;
            PM["BKRS"] = MABF.BKRS;
            PM["BLFD"] = MABF.BLFD;
            PM["TP"] = MABF.MKFTP;
            SHIFT();
            //PM["PDCDATE"] = model.DTEND;
            //PM["PDCTIMET"] = model.TMEND;             
            ABP.PDC(PM);
            StartNewJob();
        } 
    }
}
